//package com.yunhe.authority.controller.base;
//
//import com.yunhe.authority.domain.base.FirmType;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.authority.service.base.FirmTypeService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
///**
// * 单位类型Controller
// * @author liuronglei
// */
//@Api(value = "firmType", description = "单位类型", tags = {"Base_FirmType"})
//@RestController
//@RequestMapping("/types/firm")
//public class FirmTypeController {
//
//    @Autowired
//    private FirmTypeService firmTypeService;
//
//    /**
//     * 新增单位类型
//     * @param firmType 单位类型对象
//     */
//    @ApiOperation("新增单位类型")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody FirmType firmType)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        FirmType newFirmType = firmTypeService.createFirmType(firmType);
//        return new ResponseEntity<>(new ResultObject<>(newFirmType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除单位类型
//     * @param id 单位类型ID
//     */
//    @ApiOperation("根据ID删除单位类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @PathVariable("id") Long id) {
//        firmTypeService.deleteFirmType(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新单位类型
//     * @param id 单位类型ID
//     * @param firmType 单位类型对象
//     */
//    @ApiOperation("更新单位类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody FirmType firmType)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        firmType.setId(id);
//        FirmType newFirmType = firmTypeService.updateFirmType(firmType);
//        return new ResponseEntity<>(new ResultObject<>(newFirmType), HttpStatus.OK);
//    }
//
//    /**
//     * 更新单位类型
//     * @param id 单位类型ID
//     * @param code 单位类型代码
//     * @param name 单位类型编号
//     * @param title 单位类型名称
//     * @param sn 排序序号
//     * @param activity 是否可用
//     */
//    @ApiOperation("更新单位类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位类型ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "单位类型代码", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "单位类型编号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "单位类型名称", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "sn", value = "排序序号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "boolean", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(
//            @PathVariable("id") Long id,
//            @RequestParam("code") Optional<Long> code,
//            @RequestParam("name") Optional<String> name,
//            @RequestParam("title") Optional<String> title,
//            @RequestParam("sn") Optional<String> sn,
//            @RequestParam("activity") Optional<Boolean> activity)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        FirmType newFirmType = firmTypeService.updateFirmType(id, code.orElse(null), name.orElse(null),
//                title.orElse(null), sn.orElse(null), activity.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newFirmType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据单位类型ID获得单位类型
//     * @param id 单位类型ID
//     */
//    @ApiOperation("根据单位类型ID获得单位类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        FirmType FirmType = firmTypeService.findByFirmTypeId(id);
//        return new ResponseEntity<>(new ResultObject<>(FirmType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得单位类型列表
//     */
//    @ApiOperation("根据条件获得单位类型列表")
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search() {
//        Iterable<FirmType> results = firmTypeService.findFirmTypes();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//}
